import discourseComputed from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";

export default {
    setupComponent() {
      this.reopen({
        router: service(),
  
        // 获取当前路由名称，判断是否显示 banner
        @discourseComputed(
          "router.currentRouteName",
          "router.currentRoute.attributes.category.slug",
          "router.currentRoute.attributes.tag.id"
        )
        showBanner(currentRouteName, categorySlug, tagId) {
          if (this.site.mobileView) {
            return false;
          }
          if (settings.show_in_routes !== "") {
            const selectedRoutes = settings.show_in_routes.split("|");
            if (
              selectedRoutes.includes(currentRouteName) ||
              selectedRoutes.includes(`c/${categorySlug}`) ||
              selectedRoutes.includes(`tag/${tagId}`)
            ) {
              return true;
            } else {
              return false;
            }
          }
        },
      });
    },
  };
  